package com.lcxw.hxzb.friendcircle.project.system.mapper;

import com.lcxw.hxzb.friendcircle.project.system.domain.YwpdConsume;
import org.apache.ibatis.annotations.*;

@Mapper
public interface YwpdConsumeMapper {

    @Insert({
        "insert into ywpd_consume (`userId`, ",
        "`consume`)",
        "values ( #{userId}, ",
        "#{consume})"
    })
    int insert(YwpdConsume record);

    @Select({
        "select",
        "*",
        "from ywpd_consume",
        "where `userId` = #{userId}"
    })
    YwpdConsume selectByUserId(Long userId);

    @Select({
        "select",
        "consume",
        "from ywpd_consume",
        "where `userId` = #{userId}"
    })
    Integer selectConsumeByUserId(Long userId);

    @Update({
        "update ywpd_consume",
        "set ",
        "`consume` = consume + #{consume}",
        "where `userId` = #{userId}"
    })
    int updateConsumeByUserId(@Param("consume") Integer consume, @Param("userId") Long userId);

    @Delete({
        "delete from ywpd_consume",
        "where `userId` = #{userId}"
    })
    int deleteByUserId(Long userId);
}
